import request from '@/utils/request'
import { ADMIN } from '@/config/baseUrl'

// 查询部门列表
export function listDept(query) {
  return request({
    url: ADMIN + '/system/dept/list',
    method: 'get',
    params: query
  })
}



// 查询部门详细
export function getDept(branchinnercode) {
  return request({
    url: ADMIN + '/system/dept/' + branchinnercode,
    method: 'get'
  })
}

// 查询部门下拉树结构
export function treeselect() {
  return request({
    url: ADMIN + '/system/dept/treeselect',
    method: 'get'
  })
}

// 根据角色ID查询部门树结构
export function roleDeptTreeselect(rolecode) {
  return request({
    url: ADMIN + '/system/dept/roleDeptTreeselect/' + rolecode,
    method: 'get'
  })
}

export function getAddList(branchinnercode) {
  return request({
    url: ADMIN + '/system/dept/getAddList',
    method: 'get',
    params: {branchinnercode:branchinnercode}
  })
}

// 新增部门
export function addDept(data) {
  return request({
    url: ADMIN + '/system/dept',
    method: 'post',
    data: data
  })
}

// 修改部门
export function updateDept(data) {
  return request({
    url: ADMIN + '/system/dept',
    method: 'put',
    data: data
  })
}

// 删除部门
export function delDept(branchinnercodes) {
  return request({
    url: ADMIN + '/system/dept/' + branchinnercodes,
    method: 'delete'
  })
}

// 下载部门导入模板
export function importTemplate() {
  return request({
    url: ADMIN + '/system/dept/importTemplate',
    method: 'get'
  })
}

// 导出部门
export function exportDept(query) {
  return request({
    url: ADMIN + '/system/dept/export',
    method: 'post',
    data: query
  })
}

// 查询某个组织的所属一级部门
export function getFirstDeptByCode(orgCode) {
  return request({
    url: ADMIN + `/system/dept/${orgCode}`,
    method: 'get',
  })
}